<template>
    <div>
        <ul class="mui-table-view">
            <li v-for="item in newsList" :key="item.id" class="mui-table-view-cell mui-media">
                <router-link :to="'/home/newsinfo/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.images">
                    <div class="mui-media-body">
                        <h1>{{ item.article_title }}</h1>
                        <p class='mui-ellipsis'>
                            <span>发表时间：{{ item.add_time }} </span>
                            <span>点击：{{ item.article_view_times }} 次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>


export default {
  data() {
    return {
      newsList: [] // 保存新闻列表的数组
    };
  },
  methods: {
    getNewsList() {
      // 获取新闻列表
      this.$http.jsonp("?s=App.Table.Query&model_name=okayapi_article&id=1&app_key=4F07D528AB07EE72BD7F7C9263BD6705").then(result => {
        if (result.body.ret === 200) {
          // console.log(result);
          this.newsList = result.body.data.list
        } else {
          Toast("获取新闻列表失败");
        }
      });
    }
  },
  created() {
    this.getNewsList();
  }
};
</script>

<style lang="less" scoped>
.mui-table-view .mui-media-body {
  h1 {
    font-size: 14px;
  }
  .mui-ellipsis {
    font-size: 12px;
    color: #226aff;
    display: flex;
    justify-content: space-between; //两端对齐
  }
}
</style>
